package com.sskj.hangqing.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.hangqing.bean.HangqingBannerBean;
import com.sskj.hangqing.bean.NoticeBean;
import com.sskj.hangqing.http.HttpConfig;
import com.sskj.hangqing.ui.fragment.HangqingFragment;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;


public class HangqingFragmentPresenter extends BasePresenter<HangqingFragment> {

//    public void getData() {
//        httpService.getProduct(null)
//                .execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
//                    @Override
//                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
//                        HttpData<List<CoinBean>> httpData = response.body();
//                        if (httpData.getStatus() == HttpConfig.OK) {
//
//                            mView.refreshCoin(httpData.getData());
//                        } else {
//                            mView.finishRefresh();
//
//                        }
//                    }
//
//                    @Override
//                    public void onError(Response<HttpData<List<CoinBean>>> response) {
//                        super.onError(response);
//                        mView.finishRefresh();
//                    }
//                });
//    }

    public void getBanner() {
        httpService.getBanner("1")
                .execute(new JsonCallBack<HttpData<List<HangqingBannerBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<HangqingBannerBean>>> response) {
                        HttpData<List<HangqingBannerBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateBanner(httpData.getData());
                        }
                    }
                });
    }


    public void getNotice() {
        httpService.getNotice("1","10")
                .execute(new JsonCallBack<HttpData<PageBean<NoticeBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<PageBean<NoticeBean>>> response) {
                        HttpData<PageBean<NoticeBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateNotice(httpData.getData().getList());
                        }
                    }
                });
    }
}
